<template>
    <div class="content">
        <el-row style="margin-top: 260px;z-index: 1;">
        <el-col :model="user" :offset="15" :span="5">
            <el-card class="login-box" v-loading="$store.state.loading" element-loading-background="rgba(0, 0, 0, 0.8)">
            <el-form>
                <h1 class="title">欢迎使用复诊配药系统</h1>
                <el-form-item>
                <el-input type="text" v-model="user.userName" auto-complete="off" placeholder="请输入用户名..." suffix-icon="el-icon-bell"></el-input>
                </el-form-item>
                <el-form-item>
                <el-input type="password" v-model="user.password" auto-complete="off" placeholder="请输入密码..." suffix-icon="el-icon-edit"></el-input>
                </el-form-item>
                <el-form-item>
                <el-button type="primary" @click="login" :loading="$store.state.loading" class="pull-right" style="width:100%">登录</el-button>
                </el-form-item>
            </el-form>
            </el-card>
        </el-col>
        </el-row>
    </div>
</template>

<script>
    const axios = require('axios');
    export default {
    name: "Login",
    data() {
        return {
        user: {
            userName: "",
            password: ""
        }
        };
    },
    methods: {
        login() {
                // this.$http.get("http://121.196.150.130:8888/Demo/doctor/getById?id="+this.user.userName).then(res => {
                //     if (res.data.token) {
                //         console.log(res.data)
                //         this.$router.push({ path: "/mainpage" });
                //     }
                // });
                axios({
                method:"get",
                url:"http://121.196.150.130:8888/Demo/doctor/getById?id="+this.user.userName,
                }).then((res)=>{
                    // console.log(res);
                    if(res.data.state){
                        this.$router.push({ path: "/mainpage" });
                        this.GLOBAL.doctorinfo=res.data.doctor
                    }
                })
        }
    },
    mounted:function(){
        axios({
            method:"get",
            url:"http://121.196.150.130:8888/Demo/drug/findAll",
            }).then((res)=>{
                this.GLOBAL.basedrug=res.data
            })
    }
    };
</script>

<style scoped>
    .content{
        background-image: url(../assets/backgroundpic.jpg);
        height: 100%;
        width: 100%;
        background-size: 100% 100%;
        position: fixed;
    }
    .login-box {
        background: #ffffff;
        border: none;
    }

    .login-box-msg {
    
        color: #000000;
        text-align: center;
    }

    .login-box .title {
        color: #333333;
        text-align: center;
    }
</style>
